﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;
using CNotebook;

namespace NotebookS2
{
    public partial class M_BANK : RibbonForm
    {
        public M_BANK()
        {
            InitializeComponent();
        }

        public string ConnectionString { get; set; }
        public DataTable BankItems { get; set; }

        private void M_BANK_Load(object sender, EventArgs e)
        {
            BankManager oManager = new BankManager();
            
            oManager.ConnectionString = this.ConnectionString;
            oManager.Open();

            this.BankItems = oManager.GetBanks();

            oManager.Close();

            gridControl1.DataSource = this.BankItems;
            gridControl1.Refresh();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            BankManager oManager = new BankManager();

            oManager.ConnectionString = this.ConnectionString;
            oManager.Open();

            oManager.UpdateBank(this.BankItems);

            this.BankItems = oManager.GetBanks();
            oManager.Close();

            MessageBox.Show("Bank List successfully updated!!!", "Banks", MessageBoxButtons.OK, MessageBoxIcon.Information);

            gridControl1.DataSource = this.BankItems;
            gridControl1.Refresh();
        }


    }
}
